package com.ctg.payroll2.dao.workflow.imp;

import java.sql.SQLException;
import java.util.List;

import com.ctg.payroll2.bean.ComboData;
import com.ctg.payroll2.bean.filter.WorkflowAccountFilter;
import com.ctg.payroll2.bean.po.workflow.FlowUser;
import com.ctg.payroll2.dao.workflow.WorkflowAccountDao;
import com.ctg.platform.orm.ibatis.IbatisEntityDao;
import com.ctg.platform.util.Page;

@SuppressWarnings("unchecked")
public class WorkflowAccountDaoImp extends IbatisEntityDao implements WorkflowAccountDao {
	private String getNameSpace(){
		return this.getClass().getSimpleName();
	}
	
	public Page queryFlowUserByFilter(WorkflowAccountFilter filter){
		return pagedQueryByFilter(this.getClass(), filter,
				".queryFlowUserByFilter_count",
				".queryFlowUserByFilter_query");
	}
	
	public Long insertFlowUser(FlowUser user) throws SQLException{
		if (user==null) {
			return null;
		}
		getSqlMapClient().insert(getNameSpace()+ ".insertCsAccount", user);
		return (Long)getSqlMapClient().insert(getNameSpace()+ ".insertFlowUser", user);
	}
	
	public int deleteFlowUserByIds(String ids) throws SQLException{
		return getSqlMapClient().delete(getNameSpace() + ".deleteFlowUserByIds", ids);
	}
	
	public int updateFlowUser(FlowUser user) throws SQLException{
		return getSqlMapClient().update(getNameSpace() + ".updateFlowUser", user);
	}
	
	@SuppressWarnings("unchecked")
	public List<ComboData> queryFlowOrgchartComb() throws SQLException{
		return getSqlMapClient().queryForList(getNameSpace() + ".queryFlowOrgchartComb");
	}
}
